//
//  ProcessListTableViewCell.m
//  messageManager
//
//  Created by desunire on 2017/9/7.
//  Copyright © 2017年 desunire. All rights reserved.
//

#import "ProcessListTableViewCell.h"

@implementation ProcessListTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.backView.layer.masksToBounds=YES;
    self.backView.layer.borderWidth=0.5;
    self.backView.layer.cornerRadius = 10;
    self.timeLabel.layer.masksToBounds=YES;
    self.timeLabel.layer.cornerRadius=5;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)initWithProcessObject:(NSDictionary *)object{
    
    //批准通知样式单独处理
    if ([[object valueForKey:@"type"] isEqualToString:@"approval"]) {
        self.bianhao.text = [NSString stringWithFormat:@"标题:%@",[object valueForKey:@"title"]];
        self.timeLabel.text=[@"" ConvertStrToTime:[object valueForKey:@"timeCreated"] andFormat:@"yyyy-MM-dd HH:mm:ss"];
        if ([[object valueForKey:@"readFlag"] isEqualToString:@"1"]) {
            self.unreadImageView.hidden=YES;
        }
        NSString *flag;
        if ([[object valueForKey:@"type"] isEqualToString:@"problem"]) {
            flag=@"问题管理";
        }else if ([[object valueForKey:@"type"] isEqualToString:@"incident"]){
            flag=@"突发事件";
        }else if ([[object valueForKey:@"type"] isEqualToString:@"interaction"]){
            flag=@"交互管理";
        }else if ([[object valueForKey:@"type"] isEqualToString:@"change"]){
            flag=@"变更管理";
        }else if ([[object valueForKey:@"type"] isEqualToString:@"approval"]){
            flag=@"批准通知";
        }else if ([[object valueForKey:@"type"] isEqualToString:@"request"]){
            flag=@"请求管理";
        }
        self.title.text=[NSString stringWithFormat:@"类型:%@",flag];
        self.type.text=@"";
        self.backView.frame = CGRectMake(10, 40, SCREEN_WIDTH-20, 70);
    }
    else{
        self.bianhao.text = [NSString stringWithFormat:@"编号:%@",[object valueForKey:@"id"]];
        
        self.timeLabel.text=[@"" ConvertStrToTime:[object valueForKey:@"timeCreated"] andFormat:@"yyyy-MM-dd HH:mm:ss"];
        
        self.title.text=[NSString stringWithFormat:@"标题:%@",[object valueForKey:@"title"]];
        
        if ([[object valueForKey:@"readFlag"] isEqualToString:@"1"]) {
            self.unreadImageView.hidden=YES;
        }
        NSString *flag;
        if ([[object valueForKey:@"type"] isEqualToString:@"problem"]) {
            flag=@"问题管理";
        }else if ([[object valueForKey:@"type"] isEqualToString:@"incident"]){
            flag=@"突发事件";
        }else if ([[object valueForKey:@"type"] isEqualToString:@"interaction"]){
            flag=@"交互管理";
        }else if ([[object valueForKey:@"type"] isEqualToString:@"change"]){
            flag=@"变更管理";
        }else if ([[object valueForKey:@"type"] isEqualToString:@"approval"]){
            flag=@"批准通知";
        }else if ([[object valueForKey:@"type"] isEqualToString:@"request"]){
            flag=@"请求管理";
        }
        self.type.text=[NSString stringWithFormat:@"类型:%@",flag];
    }
   
    
    
    
    //self.frame = CGRectMake(0, 0, SCREEN_WIDTH, height + 90.0+kltopHeight);
    
}

@end
